package GUI;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

import Listeners.CWFrameListener;
import Model.ConferenceManager;

/**
 * This class is the frame (or window) that is the container for the GUI.
 * It will change to different panels based on UI input/actions.
 * 
 * @author Paul Schultz (ps87@uw.edu)
 * @version 11/24/2012
 */
@SuppressWarnings("serial")
public class ConferenceWizardFrame extends JFrame{
  
  private static final Dimension MIN_DIMENSION = new Dimension(950, 600);
  private JPanel my_cur_panel;
  
  /**
   * Constructs a Conference Wizard (J)Frame.
   */
	public ConferenceWizardFrame() 
	{
	  super("Conference Wizard");
	  ConferenceManager manager = new ConferenceManager();
		this.setLayout(new BorderLayout());
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		my_cur_panel = new LoginPanel(manager, this);
    add(my_cur_panel, BorderLayout.CENTER);
    setLocation(50,50);
    setMinimumSize(MIN_DIMENSION);
    this.addWindowListener(new CWFrameListener(manager));
    pack();
    setVisible(true);
	}
	
	/**
	 * Removes the previous panel from the frame and replaces it
	 * with a new JPanel passed in as next_panel.
	 * 
	 * @param next_panel The panel to replace the previous panel.
	 */
	public void setCurrentPanel(JPanel next_panel)
	{
	  this.remove(my_cur_panel);
	  my_cur_panel = next_panel;
	  this.add(my_cur_panel);
	  pack();
    setVisible(true);
	}
}
